import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
//自动导入element-plus组件
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// import { postcssPxToViewport } from './plugins/postcss-px-to-viewport' 

// https://vite.dev/config/
export default defineConfig({
  // css: {
  //   postcss: {
  //     plugins: [postcssPxToViewport()]  //配置postcss-px-to-viewport
  //   }
  // },
  plugins: [
    vue(),
    //自动导入element-plus组件  配置
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],

  resolve: {
    alias: {
      '@': path.resolve(process.cwd(), 'src')// process.cwd()是当前工作目录的绝对路径
      // '@': path.resolve(__dirname, "src") // __dirname是当前文件所在目录的绝对路径
    }
  }
})
